﻿using Common;
using Microsoft.AspNetCore.Mvc.Filters;
using System;

namespace Hotel.Fileter
{
    public class CustomExceptionFilterAttribute : Attribute, IExceptionFilter
    {
        public void OnException(ExceptionContext context)
        {
            //写日志
            LogHelper.Log.Info(context);
            LogHelper.Log.Error($"发生异常：{context.Exception.Message}");
            LogHelper.Log.Error($"详细信息：{context.Exception.StackTrace}");
            if (context.Exception.InnerException != null)
            {
                LogHelper.Log.Error($"内部异常：{context.Exception.InnerException}");
            }
        }
    }
}
